package com.csit.action;

import java.util.Date;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.csit.entity.CardCharge;
import com.csit.entity.User;
import com.csit.service.CardChargeService;
import com.csit.util.ResponseMsgUtil;
import com.opensymphony.xwork2.ModelDriven;

@ParentPackage("basePackage")
@Action("cardCharge")
public class CardChargeAction extends BaseAction implements ModelDriven<CardCharge> {

	private static final long serialVersionUID = -5043968816761273295L;

	private CardCharge charge = new CardCharge();
	
	private Integer customerID;
	
	private Date beginDate;
	
	private Date endDate;
	
	@Resource
	private CardChargeService chargeService;
	
	public CardCharge getModel() {
		return charge;
	}
	
	public void add(){
		User user = new User();
		Integer userID = (Integer) getSession(User.LOGINID);
		user.setUserID(userID);
		charge.setOperate(user);
		ResponseMsgUtil msgUtil = chargeService.addCardCharge(charge,customerID);
		ajaxJson(msgUtil.toJSON());
	}
	
	public void delete(){
		ResponseMsgUtil msgUtil = chargeService.deleteCardCharge(charge.getChargeID());
		ajaxJson(msgUtil.toJSON());
	}
	
	public void update(){
		ResponseMsgUtil msgUtil = chargeService.updateCardCharge(charge);
		ajaxJson(msgUtil.toJSON());
	}

	public void select(){
		String jsonString = chargeService.queryCardCharge(page, rows, customerID, beginDate, endDate);
		ajaxJson(jsonString);
	}
	
	public void get(){
		
	}

	public Integer getCustomerID() {
		return customerID;
	}

	public void setCustomerID(Integer customerID) {
		this.customerID = customerID;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
